_dss_editor.fireCommandOp = function(eventObj) {
	try {
		switch (eventObj.eventType) {
			case CMD_COPY:
				copyDiagram(eventObj);
				break;
			case CMD_CUT:
				break;
			case CMD_PASTE:
				pasteDiagram(eventObj);
				break;
			case CMD_DELETE:
				deleteDiagram(eventObj);
				break;
			case CMD_RECORD:
				break;
			case CMD_CHANGE_TYPE:
				break;
			case CMD_INSTANTIATE:
				editInstantiate(eventObj, YES);
				break;
			case CMD_NO_INSTANTIATE:
				editInstantiate(eventObj, NO);
				break;
			case CMD_ADD_SHADOW:
				editShadow(eventObj, YES);
				break;
			case CMD_REMOVE_SHADOW:
				editShadow(eventObj, NO);
				break;
			case CMD_DRILL_DOWN:
				drillDown(eventObj);
				break;
			case CMD_DRILL_UP:
				drillUp(eventObj);
				break;
			case CMD_EDIT_STATIC:
				break;
			case CMD_DEFINE_USER:
				break;
			case CMD_LAYOUT:
				break;
			case CMD_COMPLEXITY:
				break;
			case CMD_CHANGE_MARK:
				break;
			case CMD_SYNTAX_ERROR:
				break;
			case CMD_SHOW_CONTENT:
				editShowContent(eventObj, YES);
				break;
			case CMD_HIDE_CONTENT:										
				editShowContent(eventObj, NO);
				break;
			case CMD_SHOW_NAME:
				editShowLabel(eventObj, YES);
				break;
			case CMD_HIDE_NAME:
				editShowLabel(eventObj, NO);
				break;
			case CMD_SAVE:
				localSave(eventObj.canvas.presenterName, stringifyToLocalSaveMessage(eventObj.canvas));
				break;
			case CMD_SAVE_AS:
				completeDeactiverView('new.a', eventObj.canvas);
				break;
			case CMD_DERIVE:
				derive(eventObj);
				break;
			case CMD_GENERATE_SLIDES:
				break;
			case CMD_GENERATE_DOC:
				break;
			case CMD_GENERATE_CODE:
				break;
			case CMD_SEARCH:
				break;
			case CMD_EDIT_ARRAY:
				editArray(eventObj);
				break;
			case CMD_EXPORT_SLIDE:
				exprotSlide(eventObj);
				break;
			case CMD_IMPORT:
				importSystem(eventObj);
				break;
			default:
				break;
		}
	} catch (exc) {
		console.error(exc.stack);
	}
};

function derive(eventObj) {
	var canvas = eventObj.canvas;
	var interaction = canvas.selectionLinks[0];
	if (interaction) {
		var cmd = new DeriveCommand(interaction, canvas);
		cmd.doCommand();
	}
	canvas.update();
}

function copyDiagram(eventObj) {
	var cmd = new CopyCommand(eventObj.canvas);
	cmd.doCommand();
}

function pasteDiagram(eventObj) {
	if (eventObj.hasOwnProperty('location')) {
		var location = eventObj.location;
		var canvas = eventObj.canvas;
		var diagram = _dss_editor._toolkit.findSystemByLocation(canvas.sys, location, canvas);
		var cmd = new PasteCommand(location, diagram, canvas);
		// cmd.doCommand();
		_dss_editor._command._commandsManager.doCommand(cmd);
		canvas.update();
	}
}

function deleteDiagram(eventObj) {
	var canvas = eventObj.canvas;
	var drillSys = canvas.getCurrentDrillSystem();
	while (canvas.selectionDiagrams.length > 0) {
		var system = canvas.selectionDiagrams.pop();
		if (system == drillSys) {
			canvas.drillUp();
		}
		var cmd = new RemoveCommand(canvas, system.getParent(), system);
		_dss_editor._command._commandsManager.doCommand(cmd);
		// cmd.doCommand();
	}
	while (canvas.selectionLinks.length > 0) {
		var link = canvas.selectionLinks.pop();
		var cmd = new RemoveLinkCommand(canvas, link);
		_dss_editor._command._commandsManager.doCommand(cmd);
		// cmd.doCommand();
	}
	// _dss_editor._command.commandsManager.do(cmd);
	canvas.update();
}

function editShadow(eventObj, shadow) {
	var canvas = eventObj.canvas;
	var s = _dss_editor._toolkit.findSystemByName(canvas.sys, "test3.test4", canvas);
	console.log(s);
	for (var i = 0; i < canvas.selectionDiagrams.length; i++) {
		var diagram = canvas.selectionDiagrams[i];
		var cmd = new EditShadowCommand(diagram, shadow);
		_dss_editor._command._commandsManager.doCommand(cmd);
		_dss_editor._model.system.refreshSystemSelectionHandle(canvas);
	}
	canvas.update();
}

function editInstantiate(eventObj, instantiate) {
	var canvas = eventObj.canvas;
	for (var i = 0; i < canvas.selectionDiagrams.length; i++) {
		var diagram = canvas.selectionDiagrams[i];
		var cmd = new InstantiateCommand(diagram, instantiate);
		_dss_editor._command._commandsManager.doCommand(cmd);
		// cmd.doCommand();
	}
	canvas.update();
}

function editShowLabel(eventObj, showLabel) {
	var canvas = eventObj.canvas;
	for (var i = 0; i < canvas.selectionDiagrams.length; i++) {
		var diagram = canvas.selectionDiagrams[i];
		var command = new EditShowLabelCommand(diagram, showLabel);
		_dss_editor._command._commandsManager.doCommand(command);
		_dss_editor._model.system.refreshSystemSelectionHandle(canvas);
	}
	canvas.update();
}

function editShowContent(eventObj, showContent) {
	var canvas = eventObj.canvas;
	for (var i = 0; i < canvas.selectionDiagrams.length; i++) {
		var diagram = canvas.selectionDiagrams[i];
		// var command = new EditShowContentCommand(diagram, showContent);
		// cmd.doCommand();
		var command = new EditShowContentCommand(diagram, showContent);
		_dss_editor._command._commandsManager.doCommand(command);
		_dss_editor._model.system.refreshSystemSelectionHandle(canvas);
	}
	canvas.update();
}

function editArray(eventObj) {
	var diagram = eventObj.canvas.selectionDiagrams[eventObj.canvas.selectionDiagrams.length - 1];
	diagram.clearHandles();
	if (ArrayTool.isArrayInstance(diagram)) {
		buildArrayWindow(diagram.parent, eventObj.canvas.entity.id);
	}
}

function drillDown(eventObj) {
	eventObj.canvas.drillDown();
}

function drillUp(eventObj) {
	eventObj.canvas.drillUp();
}

function exprotSlide(eventObj) {
	var cmd = new ExportSlideCommand(eventObj.canvas);
	cmd.doCommand();
}

function importSystem(eventObj) {
	var cmd = new ImportCommand(eventObj.canvas);
	_dss_editor._command._commandsManager.doCommand(cmd);
	// cmd.doCommand();
}

